package com.tripwego.client.mapper;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.tripwego.client.ClientFactory;
import com.tripwego.client.activity.HomeActivity;
import com.tripwego.client.activity.VoyageActivity;
import com.tripwego.client.place.HomePlace;
import com.tripwego.client.place.VoyagePlace;

public class AppActivityMapper implements ActivityMapper {
	private ClientFactory clientFactory;

	public AppActivityMapper(ClientFactory clientFactory) {
		super();
		this.clientFactory = clientFactory;
	}

	@Override
	public Activity getActivity(Place place) {

		if (place instanceof HomePlace) {
			return new HomeActivity((HomePlace) place, clientFactory);
		}

		if (place instanceof VoyagePlace) {
			return new VoyageActivity((VoyagePlace) place, clientFactory);
		}

		return null;
	}
}